<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

<title>查看详情</title>
<script type="text/javascript" src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="${path }/resource/js/jquery.query.js"></script>
<script type="text/javascript" src="${path }/resource/js/systools/AjaxProxy.js"></script>
<script type="text/javascript" src="${path }/resource/plugin/layer/layer.js"></script>
<script type="text/javascript" src="${path }/resource/plugin/layer/extend/layer.ext.js"></script>
<script type="text/javascript" src="${path }/resource/plugin/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${path }/resource/js/systools/MForm.js"></script>
<link rel="stylesheet" type="text/css" href="${path }/resource/plugin/bootstrap-3.3.5/css/bootstrap.min.css"  /> 
<%-- <script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script> --%>

<!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
   	<![endif]-->
</head>
<body>

<div class="ibox-content" style="margin-left: 15px;margin-top: 10px;">
	<form class="form-horizontal" id="dataform"
		onsubmit="javascripr:return false;">

	</form>
</div>
	
     	
<script type="text/javascript">
	//初始化数据
	$(function(){
		var taskId = ${param.id};
		if(taskId != ""){
			var html = '';
			$.AjaxProxy({
				p : {
					id : taskId
				}
			}).invoke("${path}/dd/dingding/findTaskById", function(loj) {
				for(var i = 0; i < loj.getRowCount(); i++){
					html += '<input type="hidden" id="id" name="id" value="'+loj.getString(i,"id")+'">';
					html += '<div class="form-group"><label class="col-sm-2 control-label">'
						+'任务等级:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"level")+'级任务'
						+'</label></div>'
						+'<div class="form-group"><label class="col-sm-2 control-label">'
						+'任务类型:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"taskType")
						+'</label></div>'
						+'<div class="form-group"><label class="col-sm-2 control-label">'
						+'任务状态:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"status")
						+'</label></div>'
						+'<div class="form-group"><label class="col-sm-2 control-label">'
						+'创建人:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"createName")
						+'</label></div>'
						+'<div class="form-group"><label class="col-sm-2 control-label">'
						+'指派人:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"assignName")
						+'</label></div>';
						var taskType = loj.getString(i,"taskType");
						if(taskType == '开发任务'){
							html += '<div class="form-group"><label class="col-sm-2 control-label">'
								+'项目名称:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"projName")
								+'</label></div>'
								+'<div class="form-group"><label class="col-sm-2 control-label">'
								+'模块名称:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"cateName")
								+'</label></div>';
						}
					html += '<div class="form-group"><label class="col-sm-2 control-label">'
						+'预计结束时间:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getDateDD(i,"endTime")
						+'</label></div>';
						var actEndTime = loj.getString(i,"actEndTime");
						if(actEndTime!= null && actEndTime!=''){
							html += '<div class="form-group"><label class="col-sm-2 control-label">'
								+'实际结束时间:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getDateDD(i,"actEndTime")
								+'</label></div>';
						}					
						var describes = loj.getString(i,"describes");
						if(describes!= null && describes!=''){
							html += '<div class="form-group"><label class="col-sm-2 control-label">'
								+'任务描述:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"describes")
								+'</label></div>';
						}
						var assess = loj.getString(i,"assess");
						if(assess!= null && assess!=''){
							html += '<div class="form-group"><label class="col-sm-2 control-label">'
								+'任务描述:&nbsp;&nbsp;&nbsp;&nbsp;'+loj.getString(i,"assess")
								+'</label></div>';
						}
						var status = loj.getString(i,"status");
						if(status == '未开始'){
							html+='<div class="form-group " id ="start"><div class="col-sm-12 text-center">'
								+ '<a href="javascript:;" onclick="startTask()"class="btn btn-success radius">开始</a>';
								+ '</div></div>';
						}else if(status == '已完成'){
							html+='<div class="form-group " id ="start"><div class="col-sm-12 text-center">'
								+ '<a href="javascript:;" onclick="openAssess()"class="btn btn-success radius">评价</a>';
								+ '</div></div>'
						}
						
				}
				$("#dataform").html(html); 				
			});
		}	
	});
	
	function startTask(){
		var id = $("#id").val();
		if(id!=""){
			$.AjaxProxy({
				p : {
					id : id
				}
			}).invoke("${path}/dd/dingding/changeTaskStart", function(loj) {
				var status = loj.getValue("status");
				if(status== 'ok'){
					$("#start").hide();
					layer.msg(
							loj.getValue("info"), {
							icon : 1
					});
				}else{
					layer.msg(
							loj.getValue("info"), {
							icon : 2
					});
				}
			});
		}
	}
	
	function openAssess(id) {
		var id = $("#id").val();
		console.log("id=========="+id);
		layer.open({
			type : 2,
			title : "添加评论",
			area : [ '70%', '300px' ],
			maxmin : true,
			content : [ '${path}/dd/dingding/addAssess?id=' + id]
		});
	}
	
		
</script>
	
</body>
</html>